import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileReaderDemo08 {
    public static void main(String[] args) throws IOException {

        FileReader reader = new FileReader("F:\\IdeaProjects\\MyJava230203\\day27\\dir\\1.txt");
        int content;
        char[] chars = new char[10];// 10个字符
        while ((content = reader.read(chars)) != -1) {
            System.out.print(new String(chars, 0, content));
        }

        if (reader != null) {
            reader.close();
        }


        System.out.println("-----------------------------");
        FileInputStream fileInputStream = new FileInputStream("F:\\IdeaProjects\\MyJava230203\\day27\\dir\\1.txt");
        byte[] bytes = new byte[10];// 10个字节
        int len;
        while ((len = fileInputStream.read(bytes)) != -1) {
            System.out.println(new String(bytes, 0, len));
        }

        if (fileInputStream != null){
            fileInputStream.close();
        }
    }
}
